<%@ page import="home.beans.Note" %>
<%@ page import="java.util.List" %>
<%@ page import="home.db.NoteDAO" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2015/12/9
  Time: 21:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
  List<Note> data = (List<Note>) request.getAttribute("data");
%>
<html>
  <head>
    <title>$Title$</title>
    <script>
      function doDel() {
        var s = "";
        for (i = 1; i <=40; i++) {
          var c = document.getElementById("c"+i);
          if (c != null && c.checked) {
            s = s + i + ",";
          }
        }
        document.getElementById("cc").value = s;

        document.getElementById("ff").submit();
      }
    </script>
  </head>
  <body>
    <form id="ff" action="del.do">
      <%
        String msg = (String) session.getAttribute("msg");
        session.removeAttribute("msg");
        if (msg != null) {
      %>
      <div style="color: red"><%= msg %></div>
      <%
        }
      %>
    <table>
      <tr>
        <td>&nbsp;</td>
        <td>笔记标题</td>
        <td>笔记内容</td>
      </tr>
      <%
        for (Note n : data) {
      %>
      <tr>
        <td><input type="checkbox" id="c<%=n.getId() %>" /> </td>
        <td><%= n.getTitle() %></td>
        <td><%= n.getContent() %></td>
      </tr>
      <%
        }
      %>
      <input type="hidden" id="cc" name="cc"/>
    </table>
    </form>
  <br>
  <input type="button" value="新建笔记" onclick="window.location.href='new.do'"/>
  <input type="button" value="删除笔记" onclick="doDel();"/>

  </body>
</html>
